package com.zhouxiaoge.web.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import javax.xml.crypto.Data;
import java.util.Date;

/**
 * 作者： 周小哥
 * 时间： 2018-06-11 21:40
 * 邮箱： gqzmy@outlook.com
 **/
@Aspect
@Component
public class TimeAspect {

    @Around("execution(* com.zhouxiaoge.web.controller.UserController.*(..))")
    public Object handleControllerMethod(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {

        System.out.println("time aspect start");

        Object[] args = proceedingJoinPoint.getArgs();
        for (Object arg : args) {
            System.out.println("arg is " + arg);
        }
        long start = new Date().getTime();

        Object proceed = proceedingJoinPoint.proceed();

        System.out.println("time aspect 耗时： " + (new Date().getTime() - start));

        System.out.println("time aspect end");
        return proceed;
    }

}
